<template>
  <div>
    <Spin :spinning="loading" tip="Loading...">
      <FilterTable ref="table" :isSelectColumn="false" :columns="columns" :dataSource="tableList" :onColumnsChange="columns => (this.columns = columns)"> </FilterTable>
    </Spin>

    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'center'
      }"
    >
      <el-button @click="closeDrawer">关 闭</el-button>
      <el-button type="primary" @click="closeDrawer">确 认</el-button>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { queryFrozenAmountDetail } from '@/api/omFinance/RebateManage/RebatePoolQuery';

export default {
  mixins: [dictionary],
  props: ['type', 'rowData'],
  data() {
    return {
      columns: this.createdTable(),
      loading: false,
      formData: {},
      tableList: []
    };
  },
  created() {
    this.getDetail();
  },
  methods: {
    async getDetail() {
      this.loading = true;
      const res = await queryFrozenAmountDetail({ id: this.rowData.id });
      this.loading = false;

      if (res.resultCode == 200) {
        this.tableList = res.data;
      }
    },
    closeDrawer() {
      this.$emit('close', false);
    },
    createdTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          fixed: 'left',
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },

        {
          title: '单据流水编号',
          dataIndex: 'orderNo',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '经销商代码',
          dataIndex: 'dealerCode',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '经销商名称',
          dataIndex: 'dealerName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '预扣金额',
          dataIndex: 'freezeAmount',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '产品代码',
          dataIndex: 'productCode',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '产品名称',
          dataIndex: 'productName',
          align: 'center',
          width: 400,
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '预扣时间',
          dataIndex: 'createdAt',
          sorter: true,
          filter: true,
          filterType: 'date-range'
        },
        {
          title: '操作人',
          dataIndex: 'createdByName',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    }
  }
};
</script>
